A Machine-Checked Proof of the Average-Case Complexity of Quicksort in Coq
نویسندگان
چکیده
As a case-study in machine-checked reasoning about the complexity of algorithms in type theory, we describe a proof of the average-case complexity of Quicksort in Coq. The proof attempts to follow a textbook development, at the heart of which lies a technical lemma about the behaviour of the algorithm for which the original proof only gives an intuitive justification. We introduce a general framework for algorithmic complexity in type theory, combining some existing and novel techniques: algorithms are given a shallow embedding as monadically expressed functional programs; we introduce a variety of operation-counting monads to capture worstand average-case complexity of deterministic and nondeterministic programs, including the generalization to count in an arbitrary monoid; and we give a small theory of expectation for such non-deterministic computations, featuring both general map-fusion like results, and specific counting arguments for computing bounds. Our formalization of the average-case complexity of Quicksort includes a fully formal treatment of the ‘tricky’ textbook lemma, exploiting the generality of our monadic framework to support a key step in the proof, where the expected comparison count is translated into the expected length of a recorded list of all comparisons.
منابع مشابه
Verified Correctness and Security of OpenSSL HMAC
We have proved, with machine-checked proofs in Coq, that an OpenSSL implementation of HMAC with SHA256 correctly implements its FIPS functional specification and that its functional specification guarantees the expected cryptographic properties. This is the first machine-checked cryptographic proof that combines a source-program implementation proof, a compilercorrectness proof, and a cryptogra...
متن کاملVerified Analysis of Random Trees
This work is a case study of the formal verification and complexity analysis of some famous probabilistic algorithms and data structures in the proof assistant Isabelle/HOL: the expected number of comparisons in randomised quicksort, the relationship between randomised quicksort and average-case deterministic quicksort, the expected shape of an unbalanced random Binary Search Tree, and the expe...
متن کاملA Machine Learning Approach to Predicting the Smoothed Complexity of Sorting Algorithms
Smoothed analysis is a framework for analyzing the complexity of an algorithm, acting as a bridge between average and worst-case behaviour. For example, Quicksort and the Simplex algorithm are widely used in practical applications, despite their heavy worst-case complexity. Smoothed complexity aims to better characterize such algorithms. Existing theoretical bounds for the smoothed complexity o...
متن کاملA Formal Executable Semantics of the JavaCard Platform
We present a formal executable speci cation of two crucial JavaCard platform components namely the Java Card Virtual Machine JCVM and the ByteCode Veri er BCV Moreover we relate both components by giving a proof of correctness of the ByteCode Veri er Both formalisations and proofs have been machined checked using the proof assistant Coq
متن کاملA Matter of Trust: Skeptical Communication Between Coq and External Provers. (Question de confiance : communication sceptique entre Coq et des prouveurs externes)
This thesis studies the cooperation between the Coq proof assistant and external provers through proof witnesses. We concentrate on two di erent kinds of provers that can return certi cates: rst, answers coming from SAT and SMT solvers can be checked in Coq to increase both the con dence in these solvers and Coq's automation; second, theorems established in interactive provers based on Higher-O...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2008